const TAB_CONFIG = {
  //  操作
  CZ: 'CZ', //  评论
  PL: 'PL', //  修改记录
  XGJL: 'XGJL',
};

const imgType = ['jpg', 'png', 'svg', 'bmp', 'tiff', 'webp'];

const docType = ['doc', 'docx', 'xls', 'xlsx', 'csv'];


const pdfType = ['pdf']

const COM_NAME = {
  PDF: 'PDF', WORD: 'WORD', IMG: 'IMG', EMPTY: 'EMPTY'
}

const ComponentTypeConfig = [{
  comName: COM_NAME.WORD, typeList: _.concat(docType, pdfType),
}, {
  comName: COM_NAME.IMG, typeList: imgType,
},]

const getComponentTypeByFile = file => {
  if (file == null || file?.docType == null) return COM_NAME.EMPTY;
  let {docType} = file;
  let currentItem = _.find(ComponentTypeConfig, item => {
    return item.typeList.some(cItem => cItem == docType)
  })
  return currentItem == null || currentItem.comName == null ? COM_NAME.EMPTY : currentItem.comName;
}

// const showTypeConfig = _.concat(imgType, docType, pdfType);
const showTypeConfig = [];

const getFileIconByFileName = fileName => {
  let baseImg = require('@/assets/images/fileIcon/ZIP.png')
  if (fileName == null || fileName == '') {
    return baseImg
  }
  let nameList = fileName.split('.')
  let img = '';
  try {
    img = require(`@/assets/images/fileIcon/${nameList[nameList.length - 1].toUpperCase()}.png`)
  } catch (e) {
    img = baseImg
  }
  return img
}

export {TAB_CONFIG, imgType, docType, showTypeConfig, COM_NAME, getFileIconByFileName, getComponentTypeByFile}
